/**********************************************************************
* Filename: Cartao.java
* Created: 2012/04/20
* @author Fernando Brito e Abreu
**********************************************************************/
package pt.spw.copaPaises.businessLayer;

import java.util.Set;
import java.util.HashSet;

import org.contract4j5.contract.Contract;
import org.contract4j5.contract.Invar;


//	-------------------------------------------------------------------------------
//	INVARIANTS ()
/*
inv CartaoJogadorEmCampo
	(self.minuto >= self.membro.minuto_entrada)

*/

@Contract
public class Cartao
{
	public static Set<Cartao> allInstances = new HashSet<Cartao>();
	
	@Invar(value="m == null", message="dasdsa")
	private String m = "1";
	
	private int minuto;
	private TipoCartao tipo;
	private Membro membro;
	
	/**********************************************************************
	* Default constructor
	**********************************************************************/
	public Cartao()
	{
		allInstances.add(this);
	}
	
	/**********************************************************************
	* Parameterized constructor
	* @param minuto the minuto to initialize
	* @param tipo the tipo to initialize
	* @param membro the membro to initialize
	**********************************************************************/
	public Cartao(int minuto, TipoCartao tipo, Membro membro)
	{
		this.minuto = minuto;
		this.tipo = tipo;
		this.membro = membro;
		allInstances.add(this);
	}
	
	/**********************************************************************
	* Standard attribute getter
	* @return the minuto of the cartao
	**********************************************************************/
	public int minuto()
	{
		return minuto;
	}
	
	/**********************************************************************
	* Standard attribute setter
	* @param minuto the minuto to set
	**********************************************************************/
	public void setMinuto(int minuto)
	{
		this.minuto = minuto;
	}
	
	/**********************************************************************
	* Standard attribute getter
	* @return the tipo of the cartao
	**********************************************************************/
	public TipoCartao tipo()
	{
		return tipo;
	}
	
	/**********************************************************************
	* Standard attribute setter
	* @param tipo the tipo to set
	**********************************************************************/
	public void setTipo(TipoCartao tipo)
	{
		this.tipo = tipo;
	}
	
	/**********************************************************************
	* ONE2MANY getter for Cartao[*] <-> Membro[1]
	* @return the membro of the cartao
	**********************************************************************/
	public Membro membro()
	{
		return membro;
	}
	
	/**********************************************************************
	* ONE2MANY setter for Cartao[*] <-> Membro[1]
	* @param membro the membro to set
	**********************************************************************/
	public void setMembro(Membro membro)
	{
		this.membro = membro;
	}
	
	/**********************************************************************
	* User-defined operation specified in SOIL/OCL
	* @param tipo the tipo to set
	* @param minuto the minuto to set
	**********************************************************************/
	public void inicializa(TipoCartao tipo, int minuto)
	{

		//	self.tipo := tipo;
		//	 self.minuto := minuto;
		
		this.tipo = tipo;
		 this.minuto = minuto;
	}

	/* (non-Javadoc)
	* @see java.lang.Object#toString()
	*/
	@Override
	/**********************************************************************
	* Object serializer
	**********************************************************************/
	public String toString()
	{
		return "Cartao [minuto=" + minuto + ", tipo=" + tipo + ", membro=" + membro + "]\n";
	}
	

	

}
